package com.ixuestar.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class WorkDayCalculateUtils {
	
	
	/**
	 * 获取工作日
	 * @param currentDate
	 * @param days
	 * @return
	 */
	public static String getDate(Date currentDate, int days) {
        if (days == 0) {
            return new SimpleDateFormat("yyyy-MM-dd").format(currentDate);
        }

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(currentDate);

        int step = days < 0 ? -1 : 1;
        int i = 0;
        int daysAbs = Math.abs(days);
        while (i < daysAbs) {
            calendar.add(Calendar.DATE, step);
            i++;
            if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY
                    || calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {

                i--;
            }
        }
        return new SimpleDateFormat("yyyy-MM-dd").format(calendar.getTime());
    }	
}
